package server;

import java.io.Serializable;

/**
 * Defines a protocol and it's regular expressions for input and output directions.
 */
public class Protocol implements Serializable {
	private static final long serialVersionUID = 4657464982598376325L;

	/**
	 * Creates a new Protocol definition.
	 * @param protocol The protocol name.
	 * @param inReg The input regular expression.
	 * @param outReg The output regular expression.
	 */
	public Protocol(String protocol, String inReg, String outReg) {
		this.protocol = protocol;
		this.outReg = outReg;
		this.inReg = inReg;
	}

    public boolean equals(Object other) {
        if (!(other instanceof Protocol)) {
            return false;
        }

        Protocol o = (Protocol)other;
        return (
            (((protocol == null) && (o.protocol == null)) || 
                (o.protocol.equals(protocol))) &&
            (((inReg == null) && (o.inReg == null)) || 
                (o.inReg.equals(inReg))) &&
            (((outReg == null) && (o.outReg == null)) || 
                (o.outReg.equals(outReg)))
            );
    }

	public String protocol;
	public String outReg = null;
	public String inReg = null;
}
